package 滑动窗口And双指针;
/**
 * 好像可以   贪心 
 * @author I adore you
 *
 */
public class offer42连续子数组的最大和 {
	
	static int solution(int nums[]) {
//		int ans = Integer.MIN_VALUE;
		int ans = 0;
		int l = 0;
		int r = l;
		int len = nums.length;
		while( l < len){
			while(r < len) {
				if(nums[r]  + ans > ans) {
					ans = nums[r] + ans;
					r++;
				}
				else {
					l++;
					
				}
					
			}
		}
		return ans;
	}
	static int solutionOne(int nums[]) {
		int max = Integer.MIN_VALUE;
		int sum = 0;
		for(int i = 0;i < nums.length; i++) {
			if(sum <= 0)
				sum = 0;
			sum += nums[i];
			max = Math.max(sum, max);
		}
		return max;
	}
}
